package com.zz.cinema.domain;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "TS_HALL")
public class TS_Hall {

	/**
	 * create sequence SEQ_TS_HALL 
	 * minvalue 9000000 
	 * maxvalue 9999999
	 * start with 9000000
	 * increment by 1
	 * cache 20;
	 */
	@Id
	@GeneratedValue(generator = "sequenceGenerator_TS_HALL", strategy = GenerationType.SEQUENCE)
	@SequenceGenerator(name = "sequenceGenerator_TS_HALL", sequenceName = "SEQ_TS_HALL", initialValue = 9000000, allocationSize = 1)
	private int hallId;
	
	private String serialNumber;
	
	private int seatAmount;
	
	private int seatRetain;
	
	private int grade; 	//级别1-5
	
	@ManyToOne(cascade = CascadeType.ALL, targetEntity = TS_Cinema.class, fetch = FetchType.LAZY)
	@JoinColumn(name = "cinemaId", referencedColumnName = "cinemaId")
	private TS_Cinema cinema;
	
	@OneToMany(mappedBy = "hall", targetEntity = TS_ItemON.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	private Set<TS_ItemON> itemONs = new HashSet<>();
	
	public TS_Hall() {
		super();
	}
	
	
	public TS_Hall(int hallId, String serialNumber, int seatAmount, int seatRetain, int grade, TS_Cinema cinema) {
		super();
		this.hallId = hallId;
		this.serialNumber = serialNumber;
		this.seatAmount = seatAmount;
		this.seatRetain = seatRetain;
		this.grade = grade;
		this.cinema = cinema;
	}


	public int getHallId() {
		return hallId;
	}
	public void setHallId(int hallId) {
		this.hallId = hallId;
	}
	public String getSerialNumber() {
		return serialNumber;
	}
	public void setSerialNumber(String serialNumber) {
		this.serialNumber = serialNumber;
	}
	public int getSeatAmount() {
		return seatAmount;
	}
	public void setSeatAmount(int seatAmount) {
		this.seatAmount = seatAmount;
	}
	public int getSeatRetain() {
		return seatRetain;
	}
	public void setSeatRetain(int seatRetain) {
		this.seatRetain = seatRetain;
	}
	public int getGrade() {
		return grade;
	}
	public void setGrade(int grade) {
		this.grade = grade;
	}
	public TS_Cinema getCinema() {
		return cinema;
	}
	public void setCinema(TS_Cinema cinema) {
		this.cinema = cinema;
	}
	
	@Override
	public String toString() {
		return "TS_Hall [hallId=" + hallId + ", serialNumber=" + serialNumber + ", seatAmount=" + seatAmount
				+ ", seatRetain=" + seatRetain + ", grade=" + grade + ", cinema=" + cinema + ", itemONs=" + itemONs
				+ "]";
	}

}
